package com.itheima.Service.ServiceImpl;

import com.itheima.Service.ReportService;
import com.itheima.mapper.PetBranchMapper;
import com.itheima.mapper.UserPetMapper;
import com.itheima.pojo.PetBranchOption;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.Objects;

@Service
public class ReportServiceImpl implements ReportService {
    @Autowired
    private UserPetMapper userPetMapper;
    @Autowired
    private PetBranchMapper petBranchMapper;

    @Override
    public List<Map> countPetSpecies() {
        List<Map> petList = userPetMapper.countPetSpecies();
        return petList;
    }

    @Override
    public List<Map> countPetState() {
        List<Map> petState = userPetMapper.countPetState();
        return petState;
    }

    @Override
    public PetBranchOption countStoreData() {
        List<Map<String, Object>> list = petBranchMapper.countStoreData();
        List<Object> branch = list.stream().map(dataMap -> dataMap.get("branch")).toList();
        List<Object> total = list.stream().map(dataMap -> dataMap.get("total")).toList();
        return new PetBranchOption(branch,total);
    }
}
